package cn.itcast.controller;

import cn.itcast.constant.MessageConstant;
import cn.itcast.entity.Result;
import cn.itcast.pojo.Address;
import cn.itcast.service.AddressService;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/address")
public class AddressController {
    
    @Reference
    private AddressService addressService;
    
    @GetMapping("/findAll")
    public Result findAll(){

        try {
            List<Address> list = addressService.findAll();
            if(list!=null&&list.size()>0){
                return new Result(true, MessageConstant.QUERY_ADDRESS_SUCCESS,list);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new Result(false,MessageConstant.QUERY_ADDRESS_FAIL);
    } 
}
